#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
	if (argc != 2) {
		printf("usage: 4-2 pathname\n");
		return -1;
	}

	if (access(argv[1], R_OK) < 0) 
		printf("access error: %s\n",strerror(errno));
	else
		printf("access read ok!\n");

	if (access(argv[1], W_OK) < 0) 
		printf("access error: %s\n",strerror(errno));
	else
		printf("access write ok!\n");

	if (access(argv[1], X_OK) < 0) 
		printf("access error: %s\n",strerror(errno));
	else
		printf("access exec ok!\n");	

	if (access(argv[1], F_OK) < 0) 
		printf("access error: %s\n",strerror(errno));
	else
		printf("access stand ok!\n");

	return 0;
}